package com.example.springbootexamples.jsch;

import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;

public class ClientDemo {
    @Test
    public void c(){

        try {
            Socket socket=new Socket("127.0.0.1",8888);

            //socket.connect(new InetSocketAddress(8888));
            socket.setSoTimeout(10*1000);
            OutputStream outputStream=socket.getOutputStream();
            String arr[]={"hell","wor","end"};
            for(int i=0;i<arr.length;i++){
                outputStream.write(arr[i].getBytes());
                outputStream.write("\n\r".getBytes());

            }
            InputStream inputStream=socket.getInputStream();
            System.out.println("start reading ...");
            int n=inputStream.read();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
